package com.szeldon.pj.jps.qres;

public class StringResult extends AbstractQueryResult {

	private String string;

	/**
	 * 
	 * @param string
	 */
	public StringResult(String string) {
		this.string = string;
	}

	public String getString() {
		return string;
	}

	@Override
	public String toString() {
		return "string(\"" + string + "\")";
	}

	@Override
	public int compareTo(AbstractQueryResult result) {
		if (result instanceof StringResult) {
			return string.compareTo(((StringResult) result).getString());
		} else {
			throw new IllegalStateException("String result can't be compared with " + result.getClass().getName()
					+ " type.");
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj.getClass().equals(this.getClass())) {
			StringResult objResult = (StringResult) obj;
			if (string.equals(objResult.getString())) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

}
